public class JointCallExecutionControl{

    public string ManagerValue{get;set;}
    public string msg{get;set;}
    public boolean showField{get;set;}
    public List<SelectOption> ManagerList{
        get{
            if(ManagerList==null)
                ManagerList=new list<SelectOption>();
            return ManagerList;
        }
        set;
    }
    public CallPlan__c callplan{
        get{
            if(callplan==null)
                callplan=new callplan__c();
            return callplan;
        }
        set;
    }
    map<id,user> allUserMap{get;set;}
    
    public void setManager(id userId){
        if(allusermap.get(userid).managerid!=null){
            id managerid=allusermap.get(userid).managerid;
            if(AllUserMap.containskey(managerid)){
                managerlist.add(new selectoption(managerid,allusermap.get(managerid).name));
                setmanager(allusermap.get(managerid).id);
            }
        }
    }
    
    public void save(){
        list<JointCall__c> insertJointCall=new list<jointcall__c>();
        if(msg==null){
            msg='共同拜访经理一经保存将不可修改，请确认并再次点击提交按钮以保存。';
        }else{
            List<String> SelectManager=ManagerValue.split(',');
         
            //search out all monthly joint call in manager list;
          
            list<Monthly_Joint_Call__c> MonthlyJointCallList=[select id from Monthly_Joint_Call__c
                                                                                 where ownerid in:selectmanager and 
                                                                                 Year__c=:string.valueof(callplan.CallPlanDate__c.year()) and 
                                                                                 month__c=:string.valueof(callplan.CallPlanDate__c.month())
                                                                                 ];
            for(string s:selectManager){
                
            }
        }
        
    }
    
    public JointCallExecutionControl(ApexPages.StandardController controller) {
        this.controller = controller;
        AllUserMap=new Map<Id,user>([select id,managerID,FunctionDepartment__c,Title__c,name
                                          from User where FunctionDepartment__c !='Trade Sales' order by Name]);
        setmanager(userinfo.getuserid());
        msg=null;
        showfield=true;
      //  system.assert(false,callplan.JointCallManager__c);
        if(callplan.JointCallManager__c!=null && string.valueof(callplan.JointCallManager__c)!=''){
            showfield=false;
        }
    }
    
    private final ApexPages.StandardController controller;

 }